package com.a918.service.impl;

import com.a918.dao.*;
import com.a918.entity.*;
import com.a918.service.MemberService;
import com.github.pagehelper.PageHelper;
import com.github.pagehelper.PageInfo;
import org.springframework.beans.factory.annotation.Autowired;
import org.springframework.stereotype.Service;

import java.util.List;
import java.util.Map;

@Service
public class MemberServiceImp implements MemberService {

    private MemBwgMapper memBwgMapper;
    private MemPerMapper memPerMapper;
    private MemOthMapper memOthMapper;
    private Bwg2governMapper bwg2governMapper;
    private Bwg2wenwuMapper bwg2wenwuMapper;
    private Bwg2materialMapper bwg2materialMapper;
    private FrontMemberMapper frontMemberMapper;
    private RegisterFileMapper registerFileMapper;

    @Autowired
    public MemberServiceImp(MemBwgMapper memBwgMapper, MemPerMapper memPerMapper, MemOthMapper memOthMapper, Bwg2governMapper bwg2governMapper, Bwg2wenwuMapper bwg2wenwuMapper, Bwg2materialMapper bwg2materialMapper, FrontMemberMapper frontMemberMapper, RegisterFileMapper registerFileMapper) {
        this.memBwgMapper = memBwgMapper;
        this.memPerMapper = memPerMapper;
        this.memOthMapper = memOthMapper;
        this.bwg2governMapper = bwg2governMapper;
        this.bwg2wenwuMapper = bwg2wenwuMapper;
        this.bwg2materialMapper = bwg2materialMapper;
        this.frontMemberMapper = frontMemberMapper;
        this.registerFileMapper = registerFileMapper;
    }



    @Override
    public Integer insertBwg(MemBwgWithBLOBs memBwgWithBLOBs) {
        return memBwgMapper.insert(memBwgWithBLOBs);
    }

    @Override
    public void updateBwg(MemBwgWithBLOBs memBwgWithBLOBs) {
        memBwgMapper.updateByPrimaryKeySelective(memBwgWithBLOBs);
    }

    @Override
    public PageInfo<MemBwg> findmemBwgList(Map<String, String> paramMap) {
        int pno=Integer.parseInt(paramMap.get("page"));
        int pageSize=Integer.parseInt(paramMap.get("limit"));
        PageHelper.startPage(pno, pageSize);
        List<MemBwg> list =memBwgMapper.findmemBwgList();
        return new PageInfo<MemBwg>(list);
    }

    @Override
    public Integer insertPer(MemPerWithBLOBs memPerWithBLOBs) {
        return memPerMapper.insertSelective(memPerWithBLOBs);
    }

    @Override
    public void updatePer(MemPerWithBLOBs memPerWithBLOBs) {
        memPerMapper.updateByPrimaryKeySelective(memPerWithBLOBs);
    }

    @Override
    public PageInfo<MemPer> findmemPerList(Map<String, String> paramMap) {
        int pno=Integer.parseInt(paramMap.get("page"));
        int pageSize=Integer.parseInt(paramMap.get("limit"));
        PageHelper.startPage(pno, pageSize);
        List<MemPer> list =memPerMapper.findmemPerList();
        return new PageInfo<MemPer>(list);
    }

    @Override
    public Integer insertOth(MemOth memOth) {
        return memOthMapper.insertSelective(memOth);
    }

    @Override
    public void updateOth(MemOth memOth) {
        memOthMapper.updateByPrimaryKeySelective(memOth);
    }

    @Override
    public PageInfo<MemOth> findmemOthList(Map<String, String> paramMap) {
        int pno=Integer.parseInt(paramMap.get("page"));
        int pageSize=Integer.parseInt(paramMap.get("limit"));
        PageHelper.startPage(pno, pageSize);
        List<MemOth> list =memOthMapper.findmemOthList();
        return new PageInfo<MemOth>(list);
    }

    @Override
    public PageInfo<MemBwg> getBwgInfo(Map<String, String> paramMap,Integer userid) {
        int pno=Integer.parseInt(paramMap.get("page"));
        int pageSize=Integer.parseInt(paramMap.get("limit"));
        PageHelper.startPage(pno, pageSize);
        List<MemBwg> list =memBwgMapper.getBwgListByUserid(userid);
        return new PageInfo<MemBwg>(list);
    }

    @Override
    public PageInfo<MemPer> getPerInfo(Map<String, String> paramMap, Integer userid) {
        int pno=Integer.parseInt(paramMap.get("page"));
        int pageSize=Integer.parseInt(paramMap.get("limit"));
        PageHelper.startPage(pno, pageSize);
        List<MemPer> list =memPerMapper.getPerListByUserid(userid);
        return new PageInfo<MemPer>(list);
    }

    @Override
    public PageInfo<MemOth> getOthInfo(Map<String, String> paramMap, Integer userid) {
        int pno=Integer.parseInt(paramMap.get("page"));
        int pageSize=Integer.parseInt(paramMap.get("limit"));
        PageHelper.startPage(pno, pageSize);
        List<MemOth> list =memOthMapper.getOthListByUserid(userid);
        return new PageInfo<MemOth>(list);
    }

    @Override
    public PageInfo<Bwg2govern> getZFzhichiInfo(Map<String, String> paramMap, Integer bwgid) {
        int pno=Integer.parseInt(paramMap.get("page"));
        int pageSize=Integer.parseInt(paramMap.get("limit"));
        PageHelper.startPage(pno, pageSize);
        List<Bwg2govern> list =bwg2governMapper.getZFzhichiLstByBwgid(bwgid);
        return new PageInfo<Bwg2govern>(list);
    }

    @Override
    public PageInfo<Bwg2wenwu> getCangpinInfo(Map<String, String> paramMap, Integer bwgid) {
        int pno=Integer.parseInt(paramMap.get("page"));
        int pageSize=Integer.parseInt(paramMap.get("limit"));
        PageHelper.startPage(pno, pageSize);
        List<Bwg2wenwu> list =bwg2wenwuMapper.getCangpinListByBwgid(bwgid);
        return new PageInfo<Bwg2wenwu>(list);
    }

    @Override
    public void deleteBwgById(Integer id) {
        memBwgMapper.deleteByPrimaryKey(id);
    }

    @Override
    public void deletePerById(Integer id) { memPerMapper.deleteByPrimaryKey(id); }

    @Override
    public void deleteOthById(Integer id) { memOthMapper.deleteByPrimaryKey(id); }

    @Override
    public void deleteCangpinById(Integer id) { bwg2wenwuMapper.deleteByPrimaryKey(id); }

    @Override
    public void deleteZFzhichiById(Integer id) { bwg2governMapper.deleteByPrimaryKey(id); }

    @Override
    public MemBwgWithBLOBs getBwgInfoById(Integer id) {
        return memBwgMapper.selectByPrimaryKey(id);
    }

    @Override
    public MemPerWithBLOBs getPerInfoById(Integer id) {
        return memPerMapper.selectByPrimaryKey(id);
    }

    @Override
    public MemOth getOthInfoById(Integer id) {
        return memOthMapper.selectByPrimaryKey(id);
    }

    @Override
    public void insertBwgTogovern(Bwg2govern bwg2govern) {
        bwg2governMapper.insert(bwg2govern);
    }

    @Override
    public void insertBwg2wenwu(Bwg2wenwu bwg2wenwu) { bwg2wenwuMapper.insert(bwg2wenwu); }

    @Override
    public void insertBwg2material(Bwg2material bwg2material) { bwg2materialMapper.insert(bwg2material); }

    @Override
    public Bwg2wenwu getCangpinById(Integer id) { return bwg2wenwuMapper.selectByPrimaryKey(id);}

    @Override
    public List<Bwg2wenwu> getCangpinListByBwgid(Integer bwgid) {return bwg2wenwuMapper.getCangpinListByBwgid(bwgid); }

    @Override
    public List<Bwg2govern> getZFzhichiByBwgid(Integer bwgid) { return bwg2governMapper.getZFzhichiLstByBwgid(bwgid); }

    @Override
    public List<Bwg2material> getMaterialLisiByBwgid(Integer bwgid) { return bwg2materialMapper.getMaterialLisiByBwgid(bwgid); }

    @Override
    public void deleteMaterialById(Integer id) { bwg2materialMapper.deleteByPrimaryKey(id);}

    @Override
    public MemBwgWithBLOBs selectBwgId(Integer userid) {return memBwgMapper.selectBwgId(userid);}

    @Override
    public MemPerWithBLOBs selectPerId(Integer userid) {return memPerMapper.selectPerId(userid);}

    @Override
    public MemOth selectOthId(Integer userid) {return memOthMapper.selectOthId(userid);}

    @Override
    public List<RegisterFile> getRiRegisterFileByUserId(Integer userid) {
        return registerFileMapper.getRegisterFileByUserid(userid);
    }

}
